<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link href="/before/css/common.css" rel="stylesheet" tyle="text/css" />
    <link href="/before/css/style.css" rel="stylesheet" type="text/css" />
    <link href="/before/fonts/iconfont.css" rel="stylesheet" type="text/css" />
    <script src="/before/js/jquery.min.1.8.2.js" type="text/javascript"></script>
    <script src="/before/js/jquery.SuperSlide.2.1.1.js" type="text/javascript"></script>
    <script src="/before/js/common_js.js" type="text/javascript"></script>
    <script src="/before/js/footer.js" type="text/javascript"></script>
    <script src="/before/js/jquery.jumpto.js" type="text/javascript"></script>

    <link href="/after/js/laypage/skin/laypage.css" rel="stylesheet">
    <!--引用vue的js-->
    <script src="/after/js/vue/vue.min.js"></script>
    <!--分页插件-->
    <script src="/after/js/laypage/laypage.js" charset="utf-8"></script>
    <script src="/after/js/layer/layer.js" charset="utf-8"></script>

    <script type="text/javascript" src="/after/js/vue/vue.min.js"></script>
    <script src="/after/js/layer/layer.js" charset="utf-8"></script>
    <title>无标题文档</title>
</head>

<body>
<div id="app">
<!--顶部样式-->
<!--头-->
<div id="top"></div><br/><br/><br/><br/><br/><br/><br/><br/><br/>
<!--广告-->
<div style=" background-image:url(/uploads/${Active.picture}); background-position:center; background-repeat:no-repeat; height:470px;background-size:100% 100%;margin-top: 10px"></div>
    <input type="hidden" id="type" value="${Active.id}"/>
<!--团购样式-->
<div class="Inside_pages clearfix">
    <div class="group_buy">
        <div class="group_list" v-for="(item,index) in result">
            <ul class="group_info">
                <li class="group_img"><a :href="'/main/LQ_details.do?id='+item.id" target="_blank"><img  :src="'/uploads/'+item.picture"/></a></li>
                <li class="group_name">
                    <a href="#"></a>
                    <div class="group_content">{{item.name}}</div><div class="group_content">{{item.picture}}</div>
                    <div class="group_Price"><span>折扣价：</span><i>￥</i><em>{{eval(item.price*${Active.discount}).toFixed(2)}}</em></div>
                    <div class="Original_Price">原价：￥{{item.price}}</div>
                    <a @click="addBookToShop(item)" class="buy_botton">加入购物车</a>
                </li>
            </ul>
        </div>
        <div id="pagenav"></div>

    </div>
</div>
<!--右边-->
<div id="page">
    <div id="right"></div>
</div>
<!--尾-->
<div id="bottom"></div>

</div>
</body>
</html>
<script>

    var app = new Vue({
        el : '#app',
        data : {
            result : []
        }
    });
    var getActivePageList = function(curr) {
        $.ajax({
            url:"/active/ActiveBook.do",
            type:"post",
            dataType:"JSON",
            data : {
                pageNum:curr || 1,
                pageSize:8,
                id:$("#type").val()
            },
            error:function () {
                alert("错误");
            },
            success:function (msg) {
                app.result=msg.page;
                laypage({
                    cont : 'pagenav', //容器。值支持id名、原生dom对象，jquery对象,
                    pages : msg.totalPage, //总页数00
                    skin:'#FFFFFF',
                    first : '首页',
                    last : '尾页',
                    curr : curr || 1, //当前页00
                    jump : function(obj, first) { //触发分页后的回调
                        if (!first) { //点击跳页触发函数自身，并传递当前页：obj.curr
                            getActivePageList(obj.curr);
                        }
                    }
                });
            }
        });
    }
    getActivePageList();

        $("#right").load("/stage/LQ_right.ftl");
        $("#top").load("/czgIndexTop/getBtype.do");
        $("#bottom").load("/stage/Czg_index_foot.ftl");

    //  显示客服聊天界面
    function showTalk(){
        layer.open({
            type:2,
            title:'客服聊天',
            fix:'false',
            maxmin:true,
            area:['800px','700px'],
            content:'/main/skipToTalk.do',
            end:function(){
            }
        })
    }

    //    添加购物车
    function addBookToShop(item){
        console.log(item);
        var id=item.id;
        var name=item.name;
        var picture=item.picture;
        var price=eval(item.price*${Active.discount}).toFixed(2);

        if('${NowCustom.id}'==''){
           layer.msg("请先登录");
        }else{
            $.ajax({
                type:"POST",
                dataType:"json",
                url:"/main/addBookToShop.do",
                data:{
                    id:id,
                    name:name,
                    price:price,
                    picture:picture,
                    customID:'${NowCustom.id}',
                    number:1
                },
                success:function(msg){
                    layer.msg("添加成功！");
                },error:function(){
                    console.log("添加失败！");
                }
            });
        }
    }

</script>

